package thimeeeee;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author AidanPryde
 */

import java.io.*;
import thimeeeee.Control.GameController;

public class Skeleton
{
    private static boolean silent = false;
    
    private static int stage = 0;

    public static int testEset;

    public static void Silence()
    {
        silent = true;
    }
    
    public static void ShowMenu()
    {
        if(!silent)
        {
            String s = new String();

            //ciklus, amíg x/X-et nem nyomunk
            do
            {
                System.out.println("Válasszon tesztesetet a sorszám beírásával!");
                System.out.println("1. Init");
                System.out.println("2. Player move");
                System.out.println("3. Falling, collapsing");
                System.out.println("4. Robbanas");
                System.out.println("5. Put bomb");
                System.out.println("6. Beast meets player");
                System.out.println("X: Kilépés");
                System.out.println();

                //beolvasás a konzolról
                try
                {
                    InputStreamReader isr = new InputStreamReader(System.in);
                    BufferedReader br = new BufferedReader(isr);
                    s = br.readLine();
                }
                catch (Exception ex)
                {
                    System.out.println("Input hiba!");
                }

                //ha nem a kilépést választottuk, akkor a teszteset futtatása
                if (!s.equalsIgnoreCase("x")){

                    //a teszteset kiválasztása a beolvasott érték alapján
                    if (s.compareTo("1") == 0){
                        testEset = 1;
                    }
                    else if (s.compareTo("2") == 0){
                        testEset = 2;
                    }
                    else if (s.compareTo("3") == 0){
                        testEset = 3;
                    }
                    else if (s.compareTo("4") == 0){
                        testEset = 4;
                    }
                    else if (s.compareTo("5") == 0){
                        testEset = 5;
                    }
                    else if (s.compareTo("6") == 0){
                        testEset = 6;
                    }
                    GameController gc = Initialize();

                    String ats = Skeleton.Ask("Mekkora legyen a timestamp? [0/1/2]", new String[] { "0", "1", "2"});
                    int ts;
                    if(ats.compareToIgnoreCase("0") == 0)
                    {
                        ts = 0;
                    }
                    else if(ats.compareToIgnoreCase("1") == 0)
                    {
                        ts = 1;
                    }
                    else
                    {
                        ts = 2;
                    }

                    gc.Idle(ts);
                }

            } while ((s.compareTo("X") != 0) && (s.compareTo("x") != 0));
        }
    }

    public static GameController Initialize()
    {
        //az inicializálás tesztesete

        GameController gc = new GameController();
        return gc;
    }

    public static void StartFunc(String f)
    {
        if(!silent)
        {
            for (int i = 0; i < stage; i++){
                System.out.print("\t");
            }

            System.out.println(">> " + f + " ");
            stage++;
        }
    }

    public static void EndFunc(String f, String ret)
    {
        if(!silent)
        {
            stage--;
            for (int i = 0; i < stage; i++){
                System.out.print("\t");
            }
            System.out.println("<< " + f + " " + ret);
        }
    }

    public static void Create(String cName)
    {
        if(!silent)
        {
            for (int i = 0; i < stage; i++){
                System.out.print("\t");
            }
            System.out.println("\t<< " + cName + " létrehozva >>");
        }
    }

    public static String Ask(String text, String[] params){
        boolean match = false;
        String s = "";

        do
        {
            for (int i = 0; i < stage; i++)
            {
                System.out.print("\t");
            }

            System.out.print("\t?? " + text + " ");

            try
            {
                InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(isr);
                s = br.readLine();
            }
            catch (Exception ex)
            {
                System.out.println("Input hiba!");
            }


            for (int i = 0; i < params.length; i++){
                if (s.contentEquals(params[i]))
                    match = true;
            }

            if (!match)
                System.out.println("Hibas input!");
        }while(!match);
        return s;
    }

    public static String Ask(String text){
        for (int i = 0; i < stage; i++)
        {
            System.out.print("\t");
        }

        System.out.print("\t?? " + text + " ");
        String s = "";

        try
        {
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            s = br.readLine();
        }
        catch (Exception ex)
        {
            System.out.println("Input hiba!");
        }

        return s;
    }
}